package org.wyn.service.impl;

import org.wyn.mongodb.bean.User;
import org.wyn.mongodb.dao.impl.UserDao;
import org.wyn.service.ILoginService;
import org.wyn.util.CodeMD5;

import com.google.inject.Inject;

public class LoginServiceImpl implements ILoginService {

	@Override
	public User login(String userName, String password) {
		User user = userDao.findOne("userName", userName);
		if(null == user)
			return null;//无此用户
		if(CodeMD5.MD5_Code(password).equals(user.getPassword())){//对比密码
			return user;
		}else{
			return null;//用户存在密码不匹配
		}
		
	}
	@Inject
	private UserDao userDao;
	public UserDao getUserDao() {
		return userDao;
	}
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
}
